<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Insert title here</title>
  <script src="js/jquery-3.2.1.min.js"></script>
  <link rel="stylesheet" href="layui/css/layui.css">


</head>
<body>
 <div><b>代码提交</b></div>
 <div>代码粘贴区域</div>
 <form id="form" action="submitcode" method="post">
   
   <div>
   <div>
    <textarea id="code" placeholder="请输入内容"  name="code" rows="20" cols="70">
      
    </textarea>
    <input type="button" class="layui-btn" onclick="bianyi()" value="编译测试">
    <textarea id="code1"  rows="20" cols="70">
  
    </textarea>
   </div>
   
   
  <br>
  <input type="button" class="layui-btn" onclick="submitcode()" value="提交代码">
</div>

</form>
<script src="layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script type="text/javascript">



  function submitcode(){

 
    var code = $("#code").val();
    var workid = ${workid}
    var testid = ${testid}
    var worktitle = "${worktitle}"
    var questionid = ${questionid}
    var form = $("#form")
    var tmpInput=$("<input type='text' name='workid'/>");
    tmpInput.attr("value", workid);
    var tmpInput1=$("<input type='text' name='questionid'/>");
    tmpInput1.attr("value", questionid);
    var tmpInput2=$("<input type='text' name='testid'/>");
    tmpInput2.attr("value", testid);
    var tmpInput3=$("<input type='text' name='worktitle'/>");
    tmpInput3.attr("value", worktitle);
    form.append(tmpInput)
    form.append(tmpInput1)
    form.append(tmpInput2)
    form.append(tmpInput3)
    form.submit();
  }
  
  function bianyi(){
	  var code = $("#code").val();
	   $.ajax({
		   url:"bianyi",
		   contentType: 'text/plain,charset=utf-8',
		   data:{
			   "code":code
		   },
		   success:function(data){
			   
			   $("#code1").text(data)
		   }
	   })
  }
  </script>



<script>
layui.use('code', function(){
  
  //layui.code(); 实际使用时，执行该方法即可。而此处注释是因为修饰器在别的js中已经执行过了
});
</script>
</body>
</html>